home *** CD-ROM | disk | FTP | other *** search
- Path: news.nask.org.pl!usenet
- From: flssoft@blue.maloka.waw.pl (Grzegorz (FLS))
- Newsgroups: comp.lang.c++
- Subject: Re: HELP with child windows
- Date: Mon, 01 Apr 1996 00:53:30 GMT
- Organization: Research and Academic Computer Network
- Message-ID: <4jn5of$s1a@bilbo.nask.org.pl>
- References: <4jeqas$g5p@news.bellglobal.com>
- NNTP-Posting-Host: s111.maloka.waw.pl
- X-Newsreader: Forte Free Agent v0.46
-
- bogdanfl@aei.ca (Bogdan Florescu) wrote:
-
- >In MS Visual C++ v 1.5, I need to do this: I have two edit boxes. When
- >I select "New" from the menu, it should set a blinking cursor in the
- >box that I want, so I can start immediately entering data, without
- >selecting first the box with the mouse. How do I do this? How do I
- >transfer the control from one window to another?
-
- >Thanks.
-
- Use a focus. I suppose that the edit boxes are in dialog window. In
- this way, you have to have IDs for them (like ID_EDIT_FIRST,
- ID_EDIT_SECOND). You have two ways to do that. The first one is to use
- <CWnd::GetDlgItem()> function to obtain a CWnd* pointer of neede
- control. This is example in a dialog method:
- ...
- CWnd* pItemWnd = GetDlgItem( ID_EDIT_FIRST ) ;
-
- if ( pItemWnd != NULL )
- pItemWnd->SetFocus() ;
- ...
-
- or
- GetDlgItem( ID_EDIT_FIRST )->SetFocus() ;
-
- if you are sure that you have an ID_EDIT_FIRST control.
-
- The second one is to use MFC Class Wizard's feature. You can add a
- variable attached to the control.
- Launch Wizard,
- select Member Variables,
- select ID_EDIT_FIRST line,
- click Add Variable...,
- write a variable name like m_c_edit_first,
- in Property combo select Control line,
- click OK
-
- Note that in second solution you cannot attach two variables to the
- same control (one for value, second for control). Of course Wizard
- does not mind if you done it, but you will have some problems after
- that.
- Anyway, the first solution will work always (?), and I suggest you to
- use it.
-
- Regards,
-
- Grzegorz
-
-
-